From 4b650cb4fd49b9c8bb7c4bc20c52757d3d6322e0 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Sat, 30 Jun 2018 15:05:55 -0600 Subject: [PATCH] use member brace initializes and default constructors. (#214) --- defs.h | 19 +++++++++---------- googledir.cc | 4 +--- jeeps/gps.h | 9 +++------ kml.cc | 4 ++-- main.cc | 2 +- mmo.cc | 5 +---- tpo.cc | 12 +++--------- 7 files changed, 20 insertions(+), 35 deletions(-) diff --git a/defs.h b/defs.h index 1261d9d3c..eb5a0be10 100644 --- a/defs.h +++ b/defs.h @@ -253,10 +253,12 @@ typedef enum { class utf_string { public: - utf_string() : - is_html(false) - {}; - bool is_html; + utf_string() = default; + utf_string(bool html, const QString& str) : + is_html{html}, + utfstring{str} + {} + bool is_html{false}; QString utfstring; }; @@ -312,11 +314,8 @@ typedef struct format_specific_data { class gb_color { public: - gb_color() : - bbggrr(-1), - opacity(255) {} - int bbggrr; // 32 bit color: Blue/Green/Red. < 0 == unknown. - unsigned char opacity; // 0 == transparent. 255 == opaque. + int bbggrr{-1}; // 32 bit color: Blue/Green/Red. < 0 == unknown. + unsigned char opacity{255}; // 0 == transparent. 255 == opaque. }; @@ -340,7 +339,7 @@ void fs_chain_add(format_specific_data** chain, format_specific_data* data); class UrlLink { public: - UrlLink() { } + UrlLink() = default; UrlLink(const QString& url) : url_(url) { } diff --git a/googledir.cc b/googledir.cc index aa6a69834..c23af727f 100644 --- a/googledir.cc +++ b/googledir.cc @@ -103,9 +103,7 @@ goog_poly_e(xg_string args, const QXmlStreamAttributes*) if (instructions == nullptr) { routehead->rte_desc = QString("Step %1").arg(goog_step); } else { - utf_string utf; - utf.is_html = true; - utf.utfstring = instructions; + utf_string utf(true, instructions); char *s = strip_html(&utf); routehead->rte_desc = s; xfree(s); diff --git a/jeeps/gps.h b/jeeps/gps.h index b897f89d7..a33f1fb80 100644 --- a/jeeps/gps.h +++ b/jeeps/gps.h @@ -39,12 +39,9 @@ typedef struct GPS_SPacket { class GPS_PPacket { public: - GPS_PPacket() : type(0), n(0) { - memset(data, 0, MAX_GPS_PACKET_SIZE); - } - US type; - uint32 n; - UC data[MAX_GPS_PACKET_SIZE]; + US type{0}; + uint32 n{0}; + UC data[MAX_GPS_PACKET_SIZE]{}; }; diff --git a/kml.cc b/kml.cc index c8642eb27..5c4c2d231 100644 --- a/kml.cc +++ b/kml.cc @@ -198,8 +198,8 @@ struct { #define ICON_DIR ICON_BASE "track-directional/track-%1.png" // format string where next arg is rotational degrees. static struct { - float seq; - float step; + float seq{0.0f}; + float step{0.0f}; gb_color color; } kml_color_sequencer; #define KML_COLOR_LIMIT 204 /* allowed range [0,255] */ diff --git a/main.cc b/main.cc index 62a632d04..622ae8076 100644 --- a/main.cc +++ b/main.cc @@ -50,7 +50,7 @@ void signal_handler(int sig); class QargStackElement { public: - int argn; + int argn{0}; QStringList qargs; public: diff --git a/mmo.cc b/mmo.cc index 985656981..6bf6823a8 100644 --- a/mmo.cc +++ b/mmo.cc @@ -1291,10 +1291,7 @@ mmo_write_wpt_cb(const Waypoint* wpt) char* kml = nullptr; if (strcmp(wpt->session->name, "kml") == 0) { - utf_string tmp; - - tmp.utfstring = cx; - tmp.is_html = true; + utf_string tmp(true, cx); cx = kml = strip_html(&tmp); } str += cx; diff --git a/tpo.cc b/tpo.cc index 5ef416d60..d1036e296 100644 --- a/tpo.cc +++ b/tpo.cc @@ -495,16 +495,10 @@ static Waypoint* tpo_convert_ll(int lat, int lon) #define TRACKNAMELENGTH 256 class StyleInfo { public: - StyleInfo() { - color[0] = 0; - color[1] = 0; - color[2] = 0; - wide = dash = 0; - } QString name; - uint8_t color[3]; // keep R/G/B values separate because line_color needs BGR - uint8_t wide; - uint8_t dash; + uint8_t color[3]{0, 0, 0}; // keep R/G/B values separate because line_color needs BGR + uint8_t wide{0}; + uint8_t dash{0}; }; // Track decoder for version 3.x files. This block contains tracks -- 2.30.2